﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  
  <xs:element name="json">
    <xs:complexType>
      <xs:sequence>
        
        <xs:element name="serviceInterfaces">
          <xs:complexType>
            <xs:sequence>
              
              <xs:element maxOccurs="unbounded" name="serviceInterface">
                <xs:complexType>
                  <xs:sequence>
                    
                    <xs:element name="method" minOccurs="1" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>

                          <!-- Parameter(s) of the method -->
                          <xs:choice>
                            <xs:element name="parameter" maxOccurs="1" minOccurs="0">
                              <xs:complexType>
                                <xs:attribute name="dataType" type="xs:string" use="required"/>
                              </xs:complexType>
                            </xs:element>

                            <xs:element name="parameters" maxOccurs="1" minOccurs="0">
                              <xs:complexType>
                                <xs:sequence>
                                  <xs:element name="parameter" minOccurs="1" maxOccurs="unbounded">
                                    <xs:complexType>
                                      <xs:attribute name="name" type="xs:string" use="required" />
                                      <xs:attribute name="dataType" type="xs:string" use="required" />
                                    </xs:complexType>
                                  </xs:element>
                                </xs:sequence>
                              </xs:complexType>
                            </xs:element>
                          </xs:choice>

                          <!-- Result of the method -->
                          <xs:choice>
                            <xs:element name="result" maxOccurs="1" minOccurs="0">
                              <xs:complexType>
                                <xs:attribute name="dataType" type="xs:string" use="required"/>
                              </xs:complexType>
                            </xs:element>

                            <xs:element name="results" maxOccurs="1" minOccurs="0">
                              <xs:complexType>
                                <xs:sequence>
                                  <xs:element name="result"  minOccurs="1" maxOccurs="unbounded">
                                    <xs:complexType>
                                      <xs:attribute name="name" type="xs:string" use="required" />
                                      <xs:attribute name="dataType" type="xs:string" use="required" />
                                    </xs:complexType>
                                  </xs:element>
                                </xs:sequence>
                              </xs:complexType>
                            </xs:element>
                          </xs:choice>
                          
                        </xs:sequence>
                        
                        <xs:attribute name="name" type="xs:string" use="required" />
                        <xs:attribute name="path" type="xs:string" use="required" />
                      </xs:complexType>
                    </xs:element>
                    
                  </xs:sequence>
                  <!-- Attributes of interface -->
                  <xs:attribute name="name" type="xs:string" use="required" />
                </xs:complexType>
              </xs:element>
              
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <!--<xs:element name="datacontracts">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="datacontract">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="field">
                      <xs:complexType>
                        <xs:attribute name="type" type="xs:string" use="required" />
                        <xs:attribute name="name" type="xs:string" use="required" />
                        <xs:attribute name="friendlyName" type="xs:string" use="optional" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="name" type="xs:string" use="optional" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>-->
        
      </xs:sequence>
      
      <!-- Attributes of json -->
      <xs:attribute name="targetNamespace" type="xs:string" use="required" />
    </xs:complexType>
  </xs:element>
</xs:schema>